package org.tong.controller;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.tong.service.ServiceOne;

import java.util.Date;

@RestController
public class IndexController {

    @DubboReference(version = "1.0.0", check = false)
    private ServiceOne serviceOne;

    @RequestMapping("/")
    public String index() {
        return String.format("Welcome to dubbo-consumer -> %s", new Date().toString());
    }


    @RequestMapping("/service/{name}")
    public String service(@PathVariable(name = "name", required = true) String name) {
        return serviceOne.sayHello(name) + "\t->" + new Date().toString();
    }
}
